{% set isNav = true %} {% extends "./nav.html" %} {# 引入宏 #} {% import './macros/blog-list.html' as list %} {% import './macros/loadMore.html' as loadBtn %} {% import './macros/user-info.html' as user %} {% import './macros/fans.html' as fans %} {% import
'./macros/follow.html' as follow %} {% block headCss%}
<link rel="stylesheet" href="/css/profile.css"> {% endblock %} {% block content %}
<div class="container">
    <div class="row">
        <div class="col-lg-8">
            <h2>我的空间</h2>
            <div class="item-wrapper">
                {% if blogList.length > 0 %} {{ list.list(blogList,isCanReply = true) }} {% else %}
                <p>暂无数据</p>
                {% endif %}
            </div>
            {{ loadBtn.loadMore(pageIndex,pageSize,count,api='/api/blog/loadProfileMore/'+ userData.userInfo.userName +"/") }}
        </div>
        <!-- 右侧 -->
        <div class="col-lg-4">
            <!-- 个人信息 -->
            {{user.userInfo( user = userData.userInfo, isMe = userData.isMe, isMeFollow = userData.isMeFollow,atCount = userData.atCount )}}
            <div>
            </div>
            <!-- 粉丝列表 -->
            {{fans.showFans(count=userData.fansData.count,userList=userData.fansData.fansList) }}
            <hr>
            <div>
            </div>
            <!-- 关注列表 -->
            {{follow.showFollow(count = userData.followData.count, userList = userData.followData.followList )}}
        </div>
    </div>
</div>

{% endblock %} {% block js %} {#
<script>
    const pageIndex = ($(".btn-btn-load-more").data('page-index'));
    const pageSize = '{{pageSize}}';
    const count = ($(".btn-load-more").data('count'));
    if (count <= pageSize * pageIndex >= count) {
        $(".btn-load-more").hide();
    }
    $(".btn-load-more").click(function() {
        const pageIndex = $(this).data('page-index');
        const userName = '{{userData.userInfo.userName}}';
        console.log(pageIndex, userName)
        ajax.get(`/api/blog/loadProfileMore/${userName}/${pageIndex}`, function(err, res) {
            if (err) {
                alert(err)
            }
            console.log(res);
            $(".btn-load-more").data("page-index", pageIndex + 1);

            res.blogList.forEach(item => {
                    console.log(item.user.avatar)
                    let $image = "";
                    if (item.images) {
                        $image = `<a href="${item.images}" target="_blank">
                          <img src="${item.images}" alt="" width="150" class="blog-images">
                        </a>`
                    }
                    const $loadMoreTemplate = `
                  <div class="blog-item">
                    <div class="user-info">
                      <img src="${item.user.avatar}" alt="" class="user-avatar" width="60" height="60" style="border-radius:50%;">
                    </div>
                    <div class="blog-info">
                      <div class="blog-content">
                        <div>
                          <a href="###" class="username">${item.user.nickName}</a>
                          <span class="text">${item.content}</span>
                        </div>
                        ${$image}
                      </div>
                      <div class="create-time">
                        <p>${item.createdAtFormat}</p>
                      </div>
                    </div>
                  </div>
                `
                    $('.item-wrapper').append($loadMoreTemplate)
                })
                // 如果显示的数量=博客总量  隐藏按钮
            if (count <= pageSize * pageIndex >= count) {
                $(".btn-load-more").hide();
            }
        })
    })
</script>
#} {% endblock %}